﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using BLL;
using Models;

namespace Workflow
{
    public partial class Default : System.Web.UI.Page
    {
        public DomainUserInfo user = new DomainUserInfo();
        private UserTeamRoleManager utrm = new UserTeamRoleManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                // 获取请求上下文
                HttpContext _context = HttpContext.Current;
                //Response.Write(_context.User.Identity.Name);
                user = UserHelper.GetCurrentUserInfo(Context);
                var login = UserHelper.DirectoryPath;
                var vicoUser = new User();
                if (user != null)
                {
                    Session["DisplayName"] = user.DisplayName;
                    Session["FullName"] = user.FullName;
                    Session["Email"] = user.Email;
                    Session["Memberof"] = user.Memberof;
                    //Response.Write("用户：" + vicoUser.DisplayName + "<BR/>");
                    //Response.Write("用户全名：" + vicoUser.FullName + "<BR/>");
                    //Response.Write("邮箱地址：" + vicoUser.Email + "<BR/>");
                    //Response.Write("用户组：" + vicoUser.Memberof + "<BR/>");
                    //    if (user.Memberof.ToString() == "")
                    //    {
                    //        Session["Memberof"] = "Guest";
                    //    }
                    //    else
                    //    {
                    //        Session["Memberof"] = user.Memberof;
                    //    }
                    //判断数据库中有无用户信息，没有则增加信息
                    utrm.InsertUserInfo(Session["FullName"].ToString(), Session["DisplayName"].ToString(), Session["Email"].ToString());
                }
                //if (!String.IsNullOrEmpty(HttpContext.Current.Request["name"]))
                //{
                //    //Response.Write("<script language=javascript>window.document.location.href='Default.Aspx#2/2.1';</script>");
                //    HttpContext.Current.Response.Write("Default.Aspx#2/2.1");
                //}
                //else
                //{
                //Response.Write("<script language=javascript>window.document.location.href='Default.Aspx#1/1.1';</script>");
                //}





            }
            else
            {
                //当前用户还未登录。
            }

        }
    }
}